class Solution(object):
    def tupleSameProduct(self, nums):
        """
        :type nums: List[int]
        :rtype: int
        """

        product_nums = {}
        for i in range(0, len(nums)):
            for j in range(i + 1, len(nums)):
                product = nums[i] * nums[j]
                if product in product_nums:
                    product_nums[product] = product_nums[product] + 1
                else:
                    product_nums[product] = 1

        same_product = 0
        for product_num in product_nums.values():
            same_product = same_product + product_num * (product_num - 1) * 4

        return same_product
